********************************************************************************
***
*** 	Replication files for Zhuang, Maiting. 2022.
***
*** 	"Intergovernmental Conflict and Censorship: Evidence from China's 
***
***		Anti-Corruption Campaign" 
***
***		Journal of the European Economic Association
***
********************************************************************************

*** 	Do-file for all Tables and Figures in Appendix B

clear

global dir "your directory path"
cd "$dir"


********************************************************************************

*** TABLE B.1

use "$dir/data/ofnppanel_week.dta"

reghdfe article_week 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post, absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model_week1

reghdfe article_week 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post ///
i.month i.year mean_week_cny mean_week_duanwu mean_week_zhongqiu mean_week_congress mean_week_committee mean_week_zhengxie mean_week_renda mean_week_ccpprov mean_week_lhprov , absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model_week2


use "$dir/data/ofnppanel_month.dta"

reghdfe article_month 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post, absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model_month1

reghdfe article_month 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post ///
i.year mean_month_cny mean_month_duanwu mean_month_zhongqiu mean_month_congress mean_month_committee mean_month_zhengxie mean_month_renda mean_month_ccpprov mean_month_lhprov i.month, absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model_month2

esttab model_week1 model_week2 model_month1 model_month2 using "$dir/output/TableB1.tex", ///
	keep(1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post) b(a2) se(a2) /// 
	order(1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post) /// 
	nodepvar replace label interaction(" x ") star(* 0.10 ** 0.05 *** 0.01) booktabs noobs ///
	varlabels(1.of_high#1.post#1.own_province "\shortstack[l]{High-level official x\\Post-scandal x Same province}" ///
	0.of_high#1.post#1.own_province "\shortstack[l]{Low-level official x\\Post-scandal x Same province}" 1.of_high#1.post "\shortstack[l]{High-level official x\\Post-scandal}" ///
	0.of_high#1.post "\shortstack[l]{Low-level official x\\Post-scandal}") ///
	prefoot(`"\addlinespace"' ///
		`"\shortstack[l]{Month FE}		 & & \checkmark  &  &\checkmark   \\"' ///
	`"Year FE		 &  & \checkmark & &\checkmark   \\"' ///
	`"Chinese holidays		&  & \checkmark & &\checkmark   \\ "' ///
	`"National CCP events 		&  & \checkmark & &\checkmark     \\ "' ///
	`"Provincial CCP events 		&  & \checkmark & &\checkmark    \\ "' ///
	`"Official-newspaper-pair FE		& \checkmark  & \checkmark & \checkmark &\checkmark    \\ "' ///
	`"\midrule"') ///
	fragment nomtitle nonumber nolines 	stats(N r2 ymean,  fmt(%16.0fc a2 a2 ) label(  "No. of obs." "R-squared" "Mean dep. var.")) 
	
********************************************************************************

*** TABLE B.2 - Coefficients for all newspaper and high-level official provinces

use "$dir/data/ofnppanel.dta",clear

keep if of_high==1
keep if np_province2=="0"

encode np_province1, gen(np_prov)
encode of_province, gen(of_prov)

reghdfe article 1.post#i.np_prov#i.of_prov i.dofw i.month i.year date_cny_broad date_duanwu_broad date_zhongqiu_broad date_congress date_committee date_zhengxie date_renda ccpprov lhprov, noconstant absorb(onid) vce(cluster np of)
regsave using "$dir/data/prov_coefs", replace ci pval tstat 
regsave using "$dir/output/TableB2", replace table(ind_provinces, parentheses(stderr) asterisk() format(%5.3f))

***

use "$dir/output/TableB2.dta",clear

keep if ustrpos(var,"post")>0
replace var=usubinstr(var,"1.post#","",.)
split var, parse(_)
egen np_prov = sieve(var1), keep(n)
egen of_prov = sieve(var2), keep(n)
foreach x in np of{
    destring `x'_prov,replace
	merge m:1 `x'_prov using "$dir/data/`x'_prov_code.dta"
	keep if _merge==3
	drop _merge
}
drop if inlist(np_prov_en,"Fujian","Gansu","Shanghai","Beijing","Zhejiang")==1
keep ind_provinces *prov_en var4
sort of_prov np_prov var4

reshape wide ind_provinces, i(of_prov_en var4) j(np_prov_en) string
rename ind_provinces* *
drop var4
save "$dir/output/TableB2.dta",replace

***

use "$dir/data/prov_coefs.dta"

keep if ustrpos(var,"post")>0
keep var coef
split var, parse(#)
egen np_prov = sieve(var2), keep(n)
egen of_prov = sieve(var3), keep(n)
foreach x in np of{
    destring `x'_prov,replace
	merge m:1 `x'_prov using "$dir/data/`x'_prov_code.dta"
	keep if _merge==3
	drop _merge
}
keep if np_prov_cn==of_prov_cn
drop if np_prov_cn=="central"
keep coef of_prov_en
rename of_prov_en prov_en
save "$dir/data/prov_coefs.dta",replace

********************************************************************************

*** TABLE B.3

use "$dir/data/ofnppanel.dta",clear

bys onid: egen onid_mean=mean(article) 

preserve
keep if onid_mean>0

ppmlhdfe number 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post i.dofw i.month i.year date_cny_broad date_duanwu_broad date_zhongqiu_broad date_congress date_committee date_zhengxie date_renda ccpprov lhprov if onid_mean>0, absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model1

reghdfe article 1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post i.dofw i.month i.year date_cny_broad date_duanwu_broad date_zhongqiu_broad date_congress date_committee date_zhengxie date_renda ccpprov lhprov if onid_mean>0, absorb(onid) vce(cluster np of)
estadd ysumm
estimates store model2

esttab model1 model2 using "$dir/output/TableB3.tex", ///
	keep(1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post) b(a2) se(a2) /// 
	order(1.of_high#1.post#1.own_province 1.of_high#1.post 0.of_high#1.post#1.own_province 0.of_high#1.post) /// 
	nodepvar replace label interaction(" x ") star(* 0.10 ** 0.05 *** 0.01) booktabs noobs ///
	varlabels(1.of_high#1.post#1.own_province "\shortstack[l]{High-level official x\\Post-scandal x Same province}" ///
	0.of_high#1.post#1.own_province "\shortstack[l]{Low-level official x\\Post-scandal x Same province}" 1.of_high#1.post "\shortstack[l]{High-level official x\\Post-scandal}" ///
	0.of_high#1.post "\shortstack[l]{Low-level official x\\Post-scandal}") ///
	fragment nomtitle nonumber nolines ///
	stats(N r2 ymean, fmt(%16.0fc a2 a2) label("No. of obs." "R-squared" "Mean dep. var."))

restore


********************************************************************************


*** FIGURE B.1 - Dynamic effects

use "$dir/data/ofnppanel_month.dta",clear

drop if month_diff<-24

gen month_d=month_diff+24

gen ophigh_month=1.of_high#month_d#1.own_province
gen oplow_month=0.of_high#month_d#1.own_province
gen high_month=1.of_high#month_d
gen low_month=0.of_high#month_d

reghdfe article_month ib23.ophigh_month ib23.oplow_month ib23.high_month ib23.low_month ///
i.year mean_month_cny mean_month_duanwu mean_month_zhongqiu mean_month_congress mean_month_committee mean_month_zhengxie mean_month_renda mean_month_ccpprov mean_month_lhprov i.month, absorb(onid) vce(cluster np of)
estadd ysumm

coefplot , keep (*ophigh_month) ///
	 omitted baselevels vertical yline(0, lcolor(black) lwidth(thin)) ysc(r(0)) ylabel(#5) levels(95)  ///
	  msymbol(diamond) msize(small) mcolor(black) ciopts(lcolor(black)) scheme(s1color) legend(off) xline(24.5, lcolor(black) lwidth(thin) lpattern(dot)) ///
	xtitle("Months since investigation announcement",margin(medium)) ///
	 ytitle(" ") xlabel(1 "-24" 4 "-21" 7 "-18" 10 "-15" 13 "-12" 16 "-9" 19 "-6" 22 "-3" 25 "0" 28 "3" 31 "6" 34 "9" 37 "12")
graph export "$dir/output/FigureB1a.pdf", replace

coefplot , keep (*oplow_month) ///
	 omitted baselevels vertical yline(0, lcolor(black) lwidth(thin)) ysc(r(0)) ylabel(#5) levels(95)  ///
	  msymbol(diamond) msize(small) mcolor(black) ciopts(lcolor(black)) scheme(s1color) legend(off) xline(24.5, lcolor(black) lwidth(thin) lpattern(dot)) ///
	xtitle("Months since investigation announcement",margin(medium)) ///
	 ytitle(" ") xlabel(1 "-24" 4 "-21" 7 "-18" 10 "-15" 13 "-12" 16 "-9" 19 "-6" 22 "-3" 25 "0" 28 "3" 31 "6" 34 "9" 37 "12")
graph export "$dir/output/FigureB1c.pdf",  replace

coefplot , keep (*.high_month) ///
	 omitted baselevels vertical yline(0, lcolor(black) lwidth(thin)) ysc(r(0)) ylabel(#5) levels(95)  ///
	  msymbol(diamond) msize(small) mcolor(black) ciopts(lcolor(black)) scheme(s1color) legend(off) xline(24.5, lcolor(black) lwidth(thin) lpattern(dot)) ///
	xtitle("Months since investigation announcement",margin(medium)) ///
	 ytitle(" ") xlabel(1 "-24" 4 "-21" 7 "-18" 10 "-15" 13 "-12" 16 "-9" 19 "-6" 22 "-3" 25 "0" 28 "3" 31 "6" 34 "9" 37 "12")
graph export "$dir/output/FigureB1b.pdf", replace

coefplot , keep (*.low_month) ///
	 omitted baselevels vertical yline(0, lcolor(black) lwidth(thin)) ysc(r(0)) ylabel(#5) levels(95)  ///
	  msymbol(diamond) msize(small) mcolor(black) ciopts(lcolor(black)) scheme(s1color) legend(off) xline(24.5, lcolor(black) lwidth(thin) lpattern(dot)) ///
	xtitle("Months since investigation announcement",margin(medium)) ///
	 ytitle(" ") xlabel(1 "-24" 4 "-21" 7 "-18" 10 "-15" 13 "-12" 16 "-9" 19 "-6" 22 "-3" 25 "0" 28 "3" 31 "6" 34 "9" 37 "12")
graph export "$dir/output/FigureB1d.pdf", replace	


********************************************************************************

*** FIGURE B.2

use  "$dir/data/articles.dta",clear

gen own_province2=1 if own_province==0
replace own_province2=0 if own_province==1

label define post 0 "Pre-announcement" 1 "Post-announcement",replace
label define own_province2 1 "Other province" 0 "Same province",replace
label define of_high 0 "Low-level official" 1 "High-level official",replace

foreach x in own_province2 post of_high{
label values `x' `x'
}

graph bar art_hlcorrupt if count==1, over(own_province2) over(post)  over(of_high) ///
scheme(s1mono) ytitle("Proportion of article headlines with corruption") xsize(8)  ylab(,nogrid)
graph export "$dir/output/FigureB2.pdf",replace

